package com.itsc.dao;

import org.hibernate.Query;

import com.itsc.entities.User;
import com.itsc.util.MD5Util;

public class AdminLoginDao extends BaseDao<User> {
	public boolean login(User user)
	{
		String hql = "from User where user_name = ? and user_pwd = ?";
		Query query = getSession().createQuery(hql);
		query.setString(0, user.getUser_name());
		query.setString(1, MD5Util.getStringMD5(user.getUser_pwd()));
		User returnuser = new User();
		returnuser = (User) query.uniqueResult();
		if(returnuser != null)
			return true;
		return false;
		
	}
	
	public User selectByUserName(String user_name)
	{
		String hql = "from User where user_name = ?";
		Query query = getSession().createQuery(hql);
		query.setString(0, user_name);
		User returnuser = new User();
		returnuser = (User) query.uniqueResult();
		return returnuser;
	}
}
